package com.bw.heishou.mvp.view;

import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.blankj.utilcode.util.ToastUtils;
import com.bw.heishou.Bean.UserBean;
import com.bw.heishou.HeiApi;
import com.bw.heishou.R;
import com.bw.heishou.Utilise.SharedPreferencesUtilise;
import com.bw.heishou.mvp.contract.UserContract;
import com.bw.heishou.mvp.model.LogModel;
import com.bw.heishou.mvp.presenter.LogPresenter;
import com.bw.lib_core.mvp.view.BaseActivity;

public  class LogActivity extends BaseActivity<LogPresenter> implements UserContract.User_View {
    private android.widget.ImageView logactBackimg;
    private android.widget.EditText logactUser;
    private android.widget.EditText logactPass;
    private android.widget.CheckBox logactCheck;
    private android.widget.Button logactLogbtn;
    private android.widget.TextView logactRegtx;
    private static final String TAG = "LogActivity";
    @Override
    public int bandlayout() {
        return R.layout.logactivity;
    }

    @Override
    public void initView() {

        logactBackimg = (ImageView) findViewById(R.id.logact_backimg);
        logactUser = (EditText) findViewById(R.id.logact_user);
        logactPass = (EditText) findViewById(R.id.logact_pass);
        logactCheck = (CheckBox) findViewById(R.id.logact_check);
        logactLogbtn = (Button) findViewById(R.id.logact_logbtn);
        logactRegtx = (TextView) findViewById(R.id.logact_regtx);

        logactBackimg.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        logactLogbtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String s = logactUser.getText().toString();
                String s1 = logactPass.getText().toString();
                if (TextUtils.isEmpty(s)||TextUtils.isEmpty(s1)){
                    ToastUtils.showShort("账号或密码为空");
                    return;
                }
                //登录逻辑
                ///videouser/login
                pPresenter =new LogPresenter(new LogModel(),LogActivity.this);
                pPresenter.logrequest(HeiApi.req,s,s1);
                //判断是否保存
            }
        });
        logactRegtx.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(LogActivity.this, RegActivity.class));
            }
        });
    }

    @Override
    public void initData() {

    }


    @Override
    public void regOk(UserBean userBean) {

    }

    @Override
    public void logOk(UserBean userBean) {
        SharedPreferencesUtilise.getInstance().put("islog",true);
        ToastUtils.showShort("登录成功");
        finish();
    }
}
